﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void log_Authenticate(object sender, AuthenticateEventArgs e)
        {
            var name = log.UserName.Trim();
            var pass = log.Password.Trim();
            var sqlCon = string.Format("select * from Users where Username='{0}' and Password='{1}'", name, pass);
            var sqlOther = DbHelper.getData(sqlCon);
            if (sqlOther.Rows.Count == 1)
            {
                var item = sqlOther.Rows[0];
                var isEnable = (bool)item.ItemArray[3];
                var isDelete = (bool)item.ItemArray[4];
                var passWord = item.ItemArray[2].ToString();
                if (isEnable)
                {
                    if (pass == passWord)
                    {
                        Response.Redirect("Default.aspx");
                    }
                    else
                    {
                        lab.Text = ("用户名或密码错误！请重试！");
                    }
                }
                    else
                    {
                        lab.Text = ("该账户已被封禁！");
                    }
            }
                    else
                    { 
                        lab.Text = ("账户不存在，请注册！！");
                    }
            
            
        }
    }
}